<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%String skin = (String) session.getAttribute("USERSKIN_SESSION");%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <!-- 卷/件管理 -->
    <title>山西省审计厅档案综合管理系统</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <jsp:include page="/inc/head.jsp" flush="true"/>
    <link rel="stylesheet" href="${basePath}/assets/bootstrap_fileinput_master/css/fileinput.min.css"/>
    <link href="${basePath}/css/webUpload/style.css" rel="stylesheet"/>
    <link href="${basePath}/css/webUpload/demo.css" rel="stylesheet"/>
    <link href="${basePath}/css/webUpload/webuploader.css" rel="stylesheet"/>
    <link href="${basePath}/js/webuploader-0.1.5/webuploader.css" rel="stylesheet"/>
    <style>
        .bootstrap-table .icon-refresh {
            padding: 3px 0;
        }
        .bootstrap-table #table .detail-view .bootstrap-table .columns {
            margin: 0 0 8px;
        }
        #showAddressModal form .form-group>label {
            width: 100px;
            text-align: right;
        }
    </style>
</head>
<body>
<div class="panel-body" style="padding-bottom:0px;">
    <div class="panel panel-default">
        <div class="panel-heading">查询条件</div>
        <div class="panel-body">
            <form id="formSearch" class="form-horizontal">
                <div class="form-group" style="margin-top:5px">
                    <label class="control-label col-sm-1" for="txt_volTitle">题名</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" id="txt_volTitle">
                    </div>
                    <label class="control-label col-sm-1" for="txt_volNo">案卷号</label>
                    <div class="col-sm-1">
                        <input type="text" class="form-control" id="txt_volNo">
                    </div>
                    <div class="col-sm-4" style="text-align:left;">
                        <button type="button" style="margin-left:50px" id="btn_query" onclick="queryParams()" class="btn btn-primary">查询</button>
                        <button type="button" style="margin-left:20px" id="btn_clean" onclick="queryParamsClean()" class="btn btn-default">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div id="toolbar" class="btn-group">
        <shiro:hasPermission name="cms:manage:edit"><button id="btn_add" type="button" class="btn btn-default" onclick="detilsAction()">
            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 信息编辑
        </button></shiro:hasPermission>
        <shiro:hasPermission name="cms:manage:delete"><button id="btn_delete" type="button" class="btn btn-default" onclick="deleteSelectAction()">
            <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 删除
        </button></shiro:hasPermission>
        <shiro:hasPermission name="cms:manage:import"><button id="btn_import" type="button" class="btn btn-default" onClick ="importAction()">
            <span class="glyphicon glyphicon-import" aria-hidden="true"></span> 导入数据
        </button></shiro:hasPermission>
        <shiro:hasPermission name="cms:manage:export">
            <%--<button id="btn_download" type="button" class="btn btn-default" onClick ="$('#table').tableExport({ type: 'excel', escape: 'false' })">--%>
            <button id="btn_download" type="button" class="btn btn-default" onClick ="exportVolAndItemAction()">
            <span class="glyphicon glyphicon-export" aria-hidden="true"></span> 导出数据
        </button></shiro:hasPermission>
        <shiro:hasPermission name="cms:manage:mount"><button id="btn_mount" type="button" class="btn btn-default" onClick ="batchMountAction()">
            <span class="glyphicon glyphicon-paperclip" aria-hidden="true"></span> 批量挂接
        </button></shiro:hasPermission>
        <shiro:hasPermission name="cms:manage:submit"><button id="btn_submit" type="button" class="btn btn-default" onclick="submitVolAction()">
            <span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> 提交
        </button></shiro:hasPermission>
        <button id="btn_submit" type="button" class="btn btn-default" onclick="refreshDataAction()">
            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 件数更新
        </button>
        <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                提交状态 <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" role="menu">
                <li><a id="notSubmit" onclick="SearchNotSubmit()" href="javascript:;">未提交</a></li>
                <li><a id="turnDown" onclick="SearchTurnDown()" href="javascript:;">已驳回</a></li>
            </ul>
        </div>
    </div>

    <div id="showAddressModal" class="modal fade bs-example-modal-lg addUpdateInfo" role="dialog"
         aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog " role="document">
            <div class="modal-content" style="width: 600px;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="againAuditLabel">文件地址</h4>
                    <div class="modal-body" style="height: 400px;">
                        <form class="form radio" role="form" style="padding-left:10px;">
                           <div class="form-group">
                               <label>选择地址：</label>
                               <label class="radio-inline">
                                   <input type="radio" name="address"  id="address_1" value="1" checked> FTP地址
                               </label>
                               <label class="radio-inline">
                                   <input type="radio" name="address" id="address_0" value="0"> 本地地址
                               </label>
                           </div>

                            <div style="width:100%;" id="FTPtable">

                                <div class="form-group">
                                    <label class="radio-inline">FTP IP：</label>
                                    <div class="form-group" style="display:inline-block;width:400px;">
                                        <input type='text' class="form-control" id="FTPIp" name="FTPIp"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="radio-inline">FTP 端口：</label>
                                    <div class="form-group" style="display:inline-block;width:400px;">
                                        <input type='text' class="form-control" id="FTPPort" name="FTPPort"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="radio-inline">FTP账号：</label>
                                    <div class="form-group" style="display:inline-block;width:400px;">
                                        <input type='text' class="form-control" id="FTPUser" name="FTPUser"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="radio-inline">FTP密码：</label>
                                    <div class="form-group" style="display:inline-block;width:400px;">
                                        <input type='text' class="form-control" id="FTPPassword" name="FTPPassword"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="radio-inline">FTP地址：</label>
                                    <div class="form-group" style="display:inline-block;width:400px;">
                                        <input type='text' class="form-control" id="FTPPath" name="FTPPath"/>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group"  style="width:100%;display:none;" id="addressDiv">
                                <label class="radio-inline">本地地址：</label>
                                <div class="form-group" style="display:inline-block;width:400px;">
                                    <input class="form-control" type='text' id="localAddress" name="localAddress"  value=''  />
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="modal-footer ">
                    <button type="button" class="btn green" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="createDefine" onclick="submitAddress(this);">确认</button>
                </div>
            </div>
        </div>
    </div>

    <table id="table"></table>
    <!-- 记录未提交和已提交条件 -->
    <input type="hidden" id="archiveStatus" value=0>
</div>
    <jsp:include page="/inc/footer.jsp" flush="true"/>
    <script src="${basePath}/js/devPublic.js"></script>
    <script src="${basePath}/assets/bootstrap_fileinput_master/js/fileinput.min.js"></script>
    <script src="${basePath}/assets/bootstrap_fileinput_master/js/locales/zh.js"></script>
    <jsp:include page="/WEB-INF/jsp/preArchive/batchMount.jsp" flush="true"/>
    <script src="${basePath}/js/webuploader-0.1.5/webuploader.min.js"></script>
    <jsp:include page="/WEB-INF/jsp/preArchive/fileUpload.jsp" flush="true"/>
    <jsp:include page="/WEB-INF/jsp/preArchive/viewOriginal.jsp" flush="true"/>
    <jsp:include page="/WEB-INF/jsp/preArchive/importData.jsp" flush="true"/>
    <jsp:include page="/WEB-INF/jsp/preArchive/deleteTypeSelect.jsp" flush="true"/>

</section>
<script>
    var $table = $('#table');
    $(function () {
        bootstrapTableAction();
        //根据单选结果获取输入地址内容
        $(".radio").find(":radio").change(function(){
            var address = $(this).val();
            //如果是本地地址
            if(address==0){
                $("#addressDiv").show();
                $("#FTPtable").hide();
            }else{
                $("#FTPtable").show();
                $("#addressDiv").hide();
            }
        })
    });

    function bootstrapTableAction() {

        $table.bootstrapTable({
            url: '${basePath}/pcwindow/volume/volList',//请求后台的URL（*）
            method: 'get',                      //请求方式（*
            toolbar: '#toolbar',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: true,                   //是否显示分页（*）
            sortable: true,                     //是否启用排序
            queryParams: "volDefaultParams",
           // queryParams: queryParamsByAction,//传递参数（*）
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 500,                       //每页的记录行数（*）
            pageList: [200,500,1000],        //可供选择的每页的行数（*）
            //search: true,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            //strictSearch: true,
            showColumns: true,                  //是否显示所有的列
            showRefresh: true,                  //是否显示刷新按钮
            minimumCountColumns: 2,             //最少允许的列数
            clickToSelect: true,                //是否启用点击选中行
            //height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
            //showToggle:true,                    //是否显示详细视图和列表视图的切换按钮
            cardView: false,                    //是否显示详细视图
            detailView: true,                   //是否显示父子表
            /*classes: "table-dark",*/
            theadClasses: "thead-dark",
            sortName: "volNo",
            /*sortOrder: "desc",*/
            columns: [
                {field: 'ck', checkbox: true},
                {field: 'volId', title: 'ID', visible:false},
                {field: 'volClass', title: '案卷类型',formatter: 'typeVolSelectFormatter',width:'100px'},
                {field: 'volStorageTime', title: '保管期限',formatter: 'storageTimeFormatter',width:'100px'},
                {field: 'volNo', title: '案卷号',sortable: true,width:'80px'},
                {field: 'volFian', title: '全宗号', visible:false,width:'80px'},
                {field: 'volTitle', title: '案卷题名'},
                {field: 'volArchiveYear', title: '归档年度',sortable: true,width:'100px'},
                {field: 'volArchiveUnit', title: '归档单位',formatter: 'orgIdConNameVolFormatter'},
                {field: 'volAuditLeader', title: '审计组长', visible:false,width:'80px'},
                {field: 'volAuditDate', title: '审计起止日期', visible:false},
                {field: 'volSecret', title: '密级',formatter: 'traKeepFormatter', visible:false,width:'80px'},
                {field: 'volStr3', title: '保密年限', visible:false,width:'80px'},
                {field: 'volInsideDate', title: '卷内起止日期', visible:false,width:'100px'},
                {field: 'volTotal', title: '总卷数', visible:false,width:'80px'},
                {field: 'volCurrent', title: '当前卷数', visible:false,width:'80px'},
                {field: 'volCaseNum', title: '案卷档号'/*,sortable: true*/},
                {field: 'volTotalPage', title: '页数', visible:false,width:'80px'},
                {field: 'volItemNumber', title: '卷内件数',width:'80px'},
                {field: 'volStr7', title: '成功件数', visible:false,width:'80px' /*formatter: 'ifOriginalFormatter'*/},
                {field: 'uploadStatus', title: '挂接状态', formatter:'uploadStatusFormatter',width:'100px' },
                {field: 'volPublicStatus', title: '是否公开', visible: false,width:'100px',formatter: 'publicStatusFormatter' },
                {field: 'volCarrier', title: '载体类型',formatter: 'carrierStatusFormatter',width:'100px' },
                {field: 'volArchiveStatus', title: '卷宗状态', visible: false, formatter: 'statusVolumeFormatter',width:'100px'},
                {field: 'createdat', title: '创建时间',formatter:'createdatAction', visible:false,width:'100px'}
            ],
            //注册加载子表的事件。注意下这里的三个参数！
            onExpandRow: function (index, row, $detail) {
                 itemTableAction(index, row, $detail);
            },
            onLoadSuccess:function(data){
                //无数据隐藏分页
                if(data && data.total == 0){
                    $('.fixed-table-pagination').hide()
                }
            }
        });
    };

    /**
     * 初始化子表格(无线循环)
     */
    function itemTableAction(index, row, $detail){
        var parentVolCarrier = row.volCarrier;
        var parentid = row.volId;
        var $child_table = $detail.html('<table  id="child_table"></table>').find('table');
        $child_table.bootstrapTable({
            url: '${basePath}/pcwindow/item/itemList',
            method: 'get',
            queryParams: { strParentID: parentid ,parentVolCarrier : parentVolCarrier},
            //ajaxOptions: { strParentID: parentid },
            clickToSelect: false,
            detailView: false,//父子表
            uniqueId: "itemId",
            dataType:'json',
            pagination: false,
            sortable: true,
            sortName: "itemPage",
            //sortOrder: "desc",                  //排序方式
            cardView: false,                    //是否显示详细视图
            showRefresh: true,                  //是否显示刷新按钮
            minimumCountColumns: 2,             //最少允许的列数
            showColumns: true,                  //是否显示所有的列
            columns: [
               /* {field: 'ck',checkbox: true},*/
                {field: 'itemNum', title: '序号',sortable: true,width:'80px'},
                {field: 'itemName',title: '文号'},
                {field: 'itemTemporary',title: '单元号', visible:false,width:'60px'},
                {field: 'itemSecret',title: '密级',formatter: 'traItemKeepFormatter', visible:false,width:'100px'},
                {field: 'itemStr6',title: '保密年限', visible:false,width:'100px'},
                {field: 'itemTitle',title: '题名'},
                {field: 'itemRespons',title: '责任者'},
                {field: 'itemCreateTime',title: '发文日期',width:'100px'},
                {field: 'itemPage',title: '页次',sortable: true,width:'80px'},
                {field: 'itemStr3',title: '挂接状态', formatter: 'statusFormatter',width:'100px',align:"center"},
                {field: 'itemStr5', title: '是否公开', visible: false,formatter: 'publicStatusFormatter',width:'100px' },
                {field: 'itemCreateDate',title: '创建时间',formatter:'createItemAction', visible:false,width:'100px'},
                {field: 'volCarrier', title: '载体类型', visible: false,width:'100px' },
                {field: 'action', title: '操作', align: 'center', width:'100px',formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
            ]
        });
    }

    //载体类型
    function carrierStatusFormatter(value, row, index) {
        if (value == '0') {
            return '<span class="label label-warning">仅实体</span>';
        } else if(value == '1'){
            return '<span class="label label-info">仅电子</span>';
        }else {
            return '<span class="label label-success">共存</span>';
        }
    }

    //是否公开
    function publicStatusFormatter(value, row, index){
        if (value == '0') {
            return '<span class="label label-warning">未公开</span>';
        } else{
            return '<span class="label label-info">公开</span>';
        }
    }

    //是否全部挂接原文
    function ifOriginalFormatter(value, row, index){
        if (value == '1') {
            return '<span class="label label-info">是</span>';
        } else if(value == '2'){
            return '<span class="label label-warning">否</span>';
        }else {
            return '<span class="label label-default">请更新数据</span>';
        }
    }

    //格式化归档单位
    function orgIdConNameVolFormatter(value, row, index){
        return orgList[value];
    }

    /**
     * 格式化卷密级
     * @param value
     * @param row
     * @param index
     */
    function traKeepFormatter(value, row, index) {
        return secretLevel[value];
    }
    /**
     * 格式化件密级
     * @param value
     * @param row
     * @param index
     */
    function traItemKeepFormatter(value, row, index) {
        return secretLevel[value];
    }

    // 格式化状态
    function statusFormatter(value, row, index) {
        console.log(row.volCarrier)
        if(row.volCarrier == 0){
            return '<span class="label label-default">-</span>';
        }else{
            if (value == '1') {
                return '<span class="label label-success">已上传</span>';
            }else {
                return '<span class="label label-info">未上传</span>';
            }
        }
    }

    //格式化期限
    function storageTimeFormatter(value, row, index){
        return storageTime[value];
    }

    /**
     * 案卷类型格式化
     */
    function typeVolSelectFormatter(value, row, index) {
        return archiveType[value];
    }

    /**
     * 卷宗状态
     */
    function statusVolumeFormatter(value, row, index){
        if (value == '0') {
            return '<span class="label label-success">新著录</span>';
        }else if(value == '3'){
            return '<span class="label label-info">已驳回</span>';
        }else {
            return '<span class="label label-info">未知</span>';
        }
    }

    /**
     *	挂接状态
     */
    function uploadStatusFormatter(value, row, index){
        var i = (row.volItemNumber) - (row.volStr7);
        if  ( i == 0)  {
            return '<span class=\"label label-success\">已完成</span>';
        } else {
            return '<span class=\"label label-warning\">未完成</span>';
        };
    }

    /**
     *	操作按钮
     */
    function actionFormatter(value, row, index) {
        if(row.volCarrier == 0){
            return '<a href="javascript:void(0)" style="color:#01579b;" onclick="guajieAction(' + row.itemId+')" >挂接</a>';
        }else{
            if(row.itemStr3=="0"||row.itemStr3==0){
                return '<a href="javascript:void(0)" style="color:#01579b;" onclick="guajieAction(' + row.itemId+')" >挂接原文</a>';

            }else {
                return '<a href="javascript:void(0)" style="color:#01579b;" onclick="detailAction(' + row.itemId+')" >查看原文</a>';

            }
        }
    }

    function guajieAction(id){
        singleVolMount(id);
    }
    //单件挂接
    function singleVolMount(itemId){
        $("#uploadSubmit").attr("data-id",itemId);
        $("#uploadSubmit").attr("data-type",1);
        $("#uploadSubmit").attr("data-fileNum",1);
        $("#uploadSubmit").attr("data-tableId","child_table");
        // 加载addmodel
        $('#showUploadModal').modal({
            keyboard: true
        });
    }

    /**
     * 跳转原文页面
     */
    function detailAction(id){
        if(id !="" && id !=null){
            $.ajax({
                type: "post",
                url: "${basePath}/pcwindow/item/viewItemOriginal",
                data: { id: id },
                success: function (data) {
                    if (data != "failure") {
                        $('#openPdfModel').modal({
                            keyboard: true
                        });
                        var url=data;
                        var str = url.substr(url.length-4,url.length-1);
                        if(str==".jpg" || str==".png"){
                            var htmlImg = '<img src="'+url+'" style=" width:100%;height: 100%;" alt="预览">';
                            $("#pdfDialog").eq(0).append(htmlImg);
                        }else{
                            var options={
                                pdfOpenParams: {
                                    pagemode: "thumbs",
                                    navpanes: '0',
                                    /*toolbar: '0',*/   //去掉工具栏,打印,下载等,,,,
                                    statusbar: '0',
                                    view: 'FitV'
                                }};
                            var myPDF = PDFObject.embed(url, "#pdfDialog", options);
                        }

                    }else {
                        Ewin.alert("获取原文失败!");
                    }
                },
                error: function () {
                    Ewin.alert('加载错误,请联系管理员!');
                }
            })
        }else{
            Ewin.alert('请选择数据!');
        }
    }

    /**
     * 清空查询条件
     */
    function queryParamsClean() {
        $("#txt_volTitle").val("");
        $("#txt_volNo").val("");
    }

    function volDefaultParams(params){
        return {
            volTitle: $("#txt_volTitle").val(),
            volNo: $("#txt_volNo").val(),
            volArchiveStatus:$("#archiveStatus").val(),
            limit: params.limit,
            offset: params.offset,
            sort: params.sort,
            order: params.order}
    }

    /**
     * 条件查询
     */
    function queryParams() {
        /*var par={
            volTitle: $("#txt_volTitle").val(),
            volNo: $("#txt_volNo").val(),
            volArchiveStatus:$("#archiveStatus").val()
        };*/
        var opt = {
            url: '${basePath}/pcwindow/volume/volList',
            silent: true
          /*  query:par*/
        };
        $table.bootstrapTable('refresh', opt);
    }
    //查询已驳回
    function SearchTurnDown() {
       /* var opt = {
            url: "/pcwindow/volumeArchive/volList?volArchiveStatus="+3,
            silent: true,
            pageNumber:1
        };*/
        $("#archiveStatus").val(3);
        //$table.bootstrapTable('refreshOptions', opt);
        var opt = {
            url: '${basePath}/pcwindow/volume/volList',
            silent: true
            /*  query:par*/
        };
        $table.bootstrapTable('refresh', opt);
    }

    //查询未提交
    function SearchNotSubmit() {
        /*$("#archiveStatus").val(0);
        var opt = {
            url: "/pcwindow/volumeArchive/volList?volArchiveStatus="+0,
            silent: true,
            pageNumber:1
        };*/
        $("#archiveStatus").val(0);
        var opt = {
            url: '/pcwindow/volume/volList',
            silent: true
            /*  query:par*/
        };
        //$table.bootstrapTable('refreshOptions', opt);
        $table.bootstrapTable('refresh', opt);
    }

    /**
     * 卷时间处理
     */
    function createdatAction(value, row, index) {
        var timeVol = row.volCreateDate;
        return formatshortDateTime(timeVol);
    }

    /**
     * 件时间处理
     */
    function createItemAction(value, row, index){
        var timeItem = value.time;
        return formatshortDateTime(timeItem);
    }

    function savedVolAction() {
        $('#carrierTypeDialog').modal({
            keyboard: true
        });
    }

    //载体类型选择跳转
    function deleteSelectAction() {
        var rows = $table.bootstrapTable('getSelections');
        if(rows.length>0){
            $('#deleteTypeDialog').modal({
                keyboard: true
            });
        }else{
            confirmEvent('请选中至少一行数据!');
        }
    }

    /**
     * 删除数据
     */
    function deleteAction(){
        var rows = $table.bootstrapTable('getSelections');
        if(rows.length>0){
            var ids = new Array();
            for (var i in rows) {
                ids.push(rows[i].volId);
            }
            var s = ids.join("-");
            var deleteTypeValue=$("input:radio[name='deleteType']:checked").val();
            $.ajax({
                type: "post",
                url: "${basePath}/pcwindow/volume/deleteVolumeAndItem",
                data: { ids: s ,deleteTypeValue:deleteTypeValue},
                success: function (data) {
                    if (data == "success") {
                        $table.bootstrapTable('refresh');
                        $('#deleteTypeDialog').modal('hide');
                    }else {
                        Ewin.alert(data);
                    }
                },
                error: function () {
                    Ewin.alert('删除错误,请联系管理员!');
                }
            });
        }else{
            confirmEvent('请选中至少一行数据!');
        }
    }

    /**
     * 查看详情页面
     */
    function detilsAction(){
        var rows = $table.bootstrapTable('getSelections');
        if(rows.length==1){
            var volIdToDetils = rows[0].volId;
            window.location.href = "${basePath}/pcwindow/arcCreate?volIdToDetils="+volIdToDetils;
        }else{
            Ewin.alert("请选中一行数据!");
        }
    }

    /**
     * 预归档提交
     */
    function submitVolAction() {
        var rows = $table.bootstrapTable('getSelections');
        if(rows.length != 0){
            var ids = new Array();
            for (var i in rows) {
                ids.push(rows[i].volId);
            }
            $.ajax({
                type: "post",
                url: "${basePath}/pcwindow/volumeAndItem/submitVolumeAndItem",
                data: { ids: ids.join("-") },
                success: function (data) {
                    if (data == "success") {
                        $table.bootstrapTable('refresh');
                    }else {
                        Ewin.alert(data);
                    }
                },
                error: function () {
                    Ewin.alert('操作错误,请联系管理员!');
                }
            })
        }else{
            Ewin.alert('请选中一行数据!');
        }
    }

    /**
     * 导入数据
     */
    function importAction(type){
        $("#errorInfo").hide();
        $("#errorSpanInfo").empty();

        $("#uploadExcel").show();
        $("#uploadLoading").hide();

        $('#openImportDataModel').modal({
            keyboard: true
        });
       // $("#volOrItem").val(type);
    }

    /**
     * 批量挂接
     */
    function batchMountAction(){
        var rows = $table.bootstrapTable('getSelections');
        if(rows.length==0){
            Ewin.alert('请选择至少一条数据!');
        }else{
            Ewin.confirm({ message: "本地或FTP地址方式上传（确定）,选择文件上传(取消)" }).on(function(e){
                var volIds = [];
                for(var index = 0;index<rows.length;index++){
                    volIds.push(rows[index].volId);
                }
                if(!e){
                    $("#uploadSubmit").attr("data-id",volIds.join(","));
                    $("#uploadSubmit").attr("data-type",0);
                    $("#uploadSubmit").attr("data-fileNum",2);
                    $("#uploadSubmit").attr("data-tableId","table");
                    // 加载addmodel
                    $('#showUploadModal').modal({
                        keyboard: true
                    });
                }else{
                    $("#FTPtable").find("input").val("");
                    $("#addressDiv").find("input").val("");
                    //加载addmodel
                    $('#showAddressModal').modal({
                        keyboard: true
                    });
                }
            });
        }
    }

    /**
     * 导出数据
     */
    function exportVolAndItemAction(){
           var volTitle=$("#txt_volTitle").val();
           var volNo=$("#txt_volNo").val();
           var volArchiveStatus=$("#archiveStatus").val();
        window.location.href="${basePath}/pcwindow/exportVolAndItem?volTitle="
            +volTitle+"&volNo="+volNo+"&volArchiveStatus="+volArchiveStatus;
    }

    /**
     * 数据刷新（更新挂接状态和件数）
     */
    function refreshDataAction(){
        $.ajax({
            type: "post",
            url: "${basePath}/pcwindow/volumeAndItem/refreshData",
            success: function (data) {
                if (data == "success") {
                    $table.bootstrapTable('refresh');
                }
            },
            error: function () {
                Ewin.alert('操作错误,请联系管理员!');
            }
        });
    }

    //提交地址信息
    function submitAddress(event) {
        $(event).attr("disabled",true);
        var rows = $table.bootstrapTable('getSelections');
        var volIds = [];
        for(var index = 0;index<rows.length;index++){
            volIds.push(rows[index].volId);
        }
        var isFtpOrAdr = $(".radio").find(":checked").val();
        console.log(isFtpOrAdr);
        var formData = new FormData();
        //如果为0，为本地地址
        if(isFtpOrAdr==0){
            formData.append("FTPIp","");
            var localAddress = $("#localAddress").val();
            console.log(localAddress);
            if(localAddress==""){
                confirmEvent("请填写地址!");
                $(event).attr("disabled",false);
                return;
            }
        }else{
            var FTPIp = $("#FTPIp").val();
            var FTPPassword = $("#FTPPassword").val();
            var FTPPort = $("#FTPPort").val();
            var FTPPath = $("#FTPPath").val();
            var FTPUser = $("#FTPUser").val();
            if(FTPIp==''&&FTPPort==""&&FTPPath==""){
                confirmEvent("请将ftp信息填写完整!");
                $(event).attr("disabled",false);
                return;
            }
            formData.append("FTPIp",$("#FTPIp").val());
        }
        formData.append("FTPUser",$("#FTPUser").val());
        formData.append("FTPPort",$("#FTPPort").val());
        formData.append("FTPPassword",$("#FTPPassword").val());
        formData.append("FTPPath",$("#FTPPath").val());
        formData.append("localAddress",$("#localAddress").val());
        formData.append("volIds",volIds.join(","));
        formData.append("type","0");
        $.ajax({
            url:'${basePath}/pcwindow/uploadByAddress',
            type:"post",
            data:formData,
            dataType:"json",
            processData: false,  //tell jQuery not to process the data
            contentType: false,  //tell jQuery not to set contentType
            success:function (data) {
                var status = data.code;
                if(status==0){
                    confirmEvent(data.message);
                    $(event).attr("disabled",false);
                    $("#showAddressModal").modal("hide");
                }else{
                    confirmEvent(data.message);
                    $(event).attr("disabled",false);
                    $("#showAddressModal").modal("hide");
                }
            }
        })
    }


</script>
</body>
</html>

